﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace FluentExport.Extensions
{
    static class TypeExtensionsMethods
    {
        public static bool IsGenericCollection(this Type type)
        {
            var interfaces = type.GetInterfaces();

            return interfaces.Any(i => i.IsGenericType && (i.GetGenericTypeDefinition() == typeof(IList<>) || i.GetGenericTypeDefinition() == typeof(IEnumerable<>)));
        }
    }
}
